@phtngyn/cms 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +90 -0
- package/dist/studio/assets/ActivityEntryRow-D--fRvWI.js +1 -0
- package/dist/studio/assets/ActivityView-D-XBBUHb.js +1 -0
- package/dist/studio/assets/CreateDocumentDialog-CH8UH1QM.js +1 -0
- package/dist/studio/assets/DocumentsView-CxRpmAxt.js +34 -0
- package/dist/studio/assets/DropdownMenu-BSb1l7fr.js +1 -0
- package/dist/studio/assets/Input-DVao38h7.js +3 -0
- package/dist/studio/assets/MediaView-BHrPIjxB.js +1 -0
- package/dist/studio/assets/Modal-VNrXGa5C.js +1 -0
- package/dist/studio/assets/OverviewView-DfP6-mLZ.js +1 -0
- package/dist/studio/assets/Select-BJZIs9sY.js +1 -0
- package/dist/studio/assets/SettingsView-CerHe-ua.js +1 -0
- package/dist/studio/assets/Skeleton-CWJNi3nS.js +1 -0
- package/dist/studio/assets/StudioPageHeader-DP9HDAF2.js +1 -0
- package/dist/studio/assets/UsersView-cP3REkH2.js +1 -0
- package/dist/studio/assets/collaboration-BLnCzfvV.js +4 -0
- package/dist/studio/assets/context-dY4fNbn3.js +1 -0
- package/dist/studio/assets/editor-CE07wW83.js +137 -0
- package/dist/studio/assets/gateway-BAyQgCse.js +10 -0
- package/dist/studio/assets/index-CjoaPLhZ.js +28 -0
- package/dist/studio/assets/index-s2rPqCmP.css +2 -0
- package/dist/studio/assets/render-BkxbK2St.js +83 -0
- package/dist/studio/assets/rolldown-runtime-DK3Fl9T5.js +1 -0
- package/dist/studio/assets/useMediaLibrary-D7qR7aBf.js +1 -0
- package/dist/studio/index.html +76 -0
- package/package.json +75 -0
- package/src/Authoring.d.ts +46 -0
- package/src/Authoring.js +1 -0
- package/src/AuthoringSchema-BQ5kbhVB.js +926 -0
- package/src/AuthoringSchema-BQ5kbhVB.js.map +1 -0
- package/src/Configuration-BGYFD2N1.js +150 -0
- package/src/Configuration-BGYFD2N1.js.map +1 -0
- package/src/Configuration.d.ts +44 -0
- package/src/Configuration.js +9 -0
- package/src/Configuration.js.map +1 -0
- package/src/DocumentEngine-Da0kWotL.js +851 -0
- package/src/DocumentEngine-Da0kWotL.js.map +1 -0
- package/src/DocumentModel.d.ts +30 -0
- package/src/DocumentModel.js +15 -0
- package/src/DocumentModel.js.map +1 -0
- package/src/HttpPaths-86qLGB90.js +15 -0
- package/src/HttpPaths-86qLGB90.js.map +1 -0
- package/src/Module.d.ts +12 -0
- package/src/Module.js +167 -0
- package/src/Module.js.map +1 -0
- package/src/StudioHttp-BTLLooh0.js +916 -0
- package/src/StudioHttp-BTLLooh0.js.map +1 -0
- package/src/connection-ZGtL54qY.js +94 -0
- package/src/connection-ZGtL54qY.js.map +1 -0
- package/src/installation-BNKaVjni.js +9128 -0
- package/src/installation-BNKaVjni.js.map +1 -0
- package/src/internal/authoring-compiler.js +120 -0
- package/src/internal/authoring-compiler.js.map +1 -0
- package/src/internal/authoring-metadata.js +163 -0
- package/src/internal/authoring-metadata.js.map +1 -0
- package/src/internal/cms-config.js +46 -0
- package/src/internal/cms-config.js.map +1 -0
- package/src/internal/component-metadata.js +37 -0
- package/src/internal/component-metadata.js.map +1 -0
- package/src/internal/configuration.js +93 -0
- package/src/internal/configuration.js.map +1 -0
- package/src/internal/document-model.js +236 -0
- package/src/internal/document-model.js.map +1 -0
- package/src/internal/field-metadata.js +6 -0
- package/src/internal/field-metadata.js.map +1 -0
- package/src/metadata-Czvi3E4K.js +190 -0
- package/src/metadata-Czvi3E4K.js.map +1 -0
- package/src/models-Citx8jBi.js +306 -0
- package/src/models-Citx8jBi.js.map +1 -0
- package/src/models-DS5ClMsH.js +153 -0
- package/src/models-DS5ClMsH.js.map +1 -0
- package/src/runtime/api.js +9 -0
- package/src/runtime/api.js.map +1 -0
- package/src/runtime/collaboration.js +40 -0
- package/src/runtime/collaboration.js.map +1 -0
- package/src/runtime/delivery/DocumentField.js +23 -0
- package/src/runtime/delivery/DocumentField.js.map +1 -0
- package/src/runtime/delivery/DocumentRenderer.js +51 -0
- package/src/runtime/delivery/DocumentRenderer.js.map +1 -0
- package/src/runtime/delivery/DocumentScope.js +41 -0
- package/src/runtime/delivery/DocumentScope.js.map +1 -0
- package/src/runtime/delivery/document-page.js +23 -0
- package/src/runtime/delivery/document-page.js.map +1 -0
- package/src/runtime/delivery/document.js +25 -0
- package/src/runtime/delivery/document.js.map +1 -0
- package/src/runtime/delivery/preview.d.ts +11 -0
- package/src/runtime/delivery/preview.js +6 -0
- package/src/runtime/delivery/preview.js.map +1 -0
- package/src/runtime/delivery/types.d.ts +80 -0
- package/src/runtime/delivery/types.js +1 -0
- package/src/runtime/delivery/useDocument.d.ts +6 -0
- package/src/runtime/delivery/useDocument.js +20 -0
- package/src/runtime/delivery/useDocument.js.map +1 -0
- package/src/runtime/delivery/useDocumentQuery.d.ts +7 -0
- package/src/runtime/delivery/useDocumentQuery.js +26 -0
- package/src/runtime/delivery/useDocumentQuery.js.map +1 -0
- package/src/runtime/installation.js +3 -0
- package/src/runtime/plugin.js +32 -0
- package/src/runtime/plugin.js.map +1 -0
- package/src/runtime/preview/CmsStudioPreviewMarker.js +15 -0
- package/src/runtime/preview/CmsStudioPreviewMarker.js.map +1 -0
- package/src/runtime/preview/comark-document.js +38 -0
- package/src/runtime/preview/comark-document.js.map +1 -0
- package/src/runtime/preview/connection.js +3 -0
- package/src/runtime/preview/controller.js +247 -0
- package/src/runtime/preview/controller.js.map +1 -0
- package/src/runtime/preview/plugin.client.js +70 -0
- package/src/runtime/preview/plugin.client.js.map +1 -0
- package/src/runtime/preview/preview.css +9 -0
- package/src/runtime/preview/protocol.d.ts +10 -0
- package/src/runtime/preview/protocol.js +11 -0
- package/src/runtime/preview/protocol.js.map +1 -0
- package/src/runtime/preview/store.js +4 -0
- package/src/runtime/preview/targets.js +102 -0
- package/src/runtime/preview/targets.js.map +1 -0
- package/src/runtime/studio-app.js +13 -0
- package/src/runtime/studio-app.js.map +1 -0
- package/src/store-Nl4uxEXx.js +221 -0
- package/src/store-Nl4uxEXx.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright (c) 2026 Phat (phtngyn). All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software and its accompanying documentation are proprietary.
|
|
4
|
+
No permission is granted to use, copy, modify, distribute, sublicense, or
|
|
5
|
+
sell this software or its documentation without prior written permission
|
|
6
|
+
from the copyright holder, except as required by applicable law.
|
|
7
|
+
|
|
8
|
+
Public availability of this software does not grant a license to it.
|
|
9
|
+
|
|
10
|
+
Third-party software included in or used by this project remains subject
|
|
11
|
+
to its own copyright notices and license terms. This notice applies only
|
|
12
|
+
to original code and documentation owned by the copyright holder and does
|
|
13
|
+
not restrict rights granted under those third-party licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# `@phtngyn/cms`
|
|
2
|
+
|
|
3
|
+
A CMS for Nuxt with an embedded Studio, collaborative editing, PostgreSQL persistence, and S3-compatible media storage. Install one module, configure your services in `cms.config.ts`, and create your first administrator in Studio. Database migrations and authentication are managed by the module.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Requires Node.js 24, Nuxt `>=4.5.0 <5`, and Vue `>=3.6.0-rc.6 <4`. Deploy as a Node server with WebSocket support; static hosting is not supported.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add @phtngyn/cms@beta zod
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Register the module in `nuxt.config.ts`:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
export default defineNuxtConfig({
|
|
17
|
+
modules: ['@phtngyn/cms'],
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Configure
|
|
22
|
+
|
|
23
|
+
Create a PostgreSQL database and an S3-compatible bucket. The database user must be able to create and migrate CMS tables. Storage credentials need bucket access and object read, write, copy, list, and delete permissions. Configure public reads through your bucket or CDN and use that URL as `publicBaseUrl`; the module does not configure public access policies.
|
|
24
|
+
|
|
25
|
+
Create `cms.config.ts` beside `nuxt.config.ts`:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { defineCmsConfig } from '@phtngyn/cms/Configuration'
|
|
29
|
+
import { z } from 'zod'
|
|
30
|
+
|
|
31
|
+
function env(name: string): string {
|
|
32
|
+
const value = process.env[name]
|
|
33
|
+
if (!value) throw new Error(`Missing ${name}`)
|
|
34
|
+
return value
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default defineCmsConfig({
|
|
38
|
+
baseUrl: env('CMS_BASE_URL'), // Website origin, e.g. http://localhost:3000
|
|
39
|
+
databaseUrl: env('DATABASE_URL'),
|
|
40
|
+
secret: env('CMS_SECRET'),
|
|
41
|
+
initializationToken: env('CMS_INITIALIZATION_TOKEN'),
|
|
42
|
+
documents: {
|
|
43
|
+
collections: {
|
|
44
|
+
pages: {
|
|
45
|
+
label: 'Page',
|
|
46
|
+
route: '/:path*',
|
|
47
|
+
schema: z.object({ title: z.string().min(1) }),
|
|
48
|
+
source: '.',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
media: {
|
|
53
|
+
publicBaseUrl: env('S3_PUBLIC_URL'),
|
|
54
|
+
storage: {
|
|
55
|
+
bucket: env('S3_BUCKET'),
|
|
56
|
+
region: env('S3_REGION'),
|
|
57
|
+
credentials: {
|
|
58
|
+
accessKeyId: env('S3_ACCESS_KEY_ID'),
|
|
59
|
+
secretAccessKey: env('S3_SECRET_ACCESS_KEY'),
|
|
60
|
+
},
|
|
61
|
+
// For an S3-compatible provider, add its endpoint and, if required:
|
|
62
|
+
// endpoint: env('S3_ENDPOINT'),
|
|
63
|
+
// forcePathStyle: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
These environment variable names are examples; configuration is executable TypeScript, so you can use your own configuration source. Supply values during Nuxt development/build and to the deployed server. Generate distinct random values of at least 32 characters for `secret` and `initializationToken`, and keep them server-side. For example, run `node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))"` separately for each.
|
|
70
|
+
|
|
71
|
+
For storage using the AWS credential chain, omit `credentials`. To create a missing bucket automatically, set `provisionBucket: true` and grant bucket-creation permission. Set `media: false` to start without uploads.
|
|
72
|
+
|
|
73
|
+
## Start editing
|
|
74
|
+
|
|
75
|
+
1. Run `pnpm dev` and open `http://localhost:3000/_cms/app`.
|
|
76
|
+
2. Enter your initialization token and create the first administrator. Initialization then closes.
|
|
77
|
+
3. Create a page in Studio, edit it, and publish it. The module provides page routing and rendering; your app must render `<NuxtPage />` in `app/app.vue` if it has a custom app shell. Existing app routes can provide custom page layouts.
|
|
78
|
+
|
|
79
|
+
Studio is bundled with the module; no separate Studio deployment or auth setup is required. Readiness is available at `/_cms/health/ready`. Restart Nuxt after changing CMS configuration or component schemas.
|
|
80
|
+
|
|
81
|
+
## Customize
|
|
82
|
+
|
|
83
|
+
- Define collections with Zod in `documents.collections`. Import `field` from `@phtngyn/cms/DocumentModel` to add field labels and input hints.
|
|
84
|
+
- Use the auto-imported `useDocument` and `useDocumentQuery` composables and `DocumentRenderer`, `DocumentScope`, and `DocumentField` components for custom rendering.
|
|
85
|
+
- Import `defineCmsBlock` from `@phtngyn/cms/Authoring` to declare editable props and slots in your Nuxt Vue components.
|
|
86
|
+
- Optionally provide `initialSources` to import Markdown documents once when the installation is first claimed.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
Proprietary. Copyright (c) 2026 Phat (phtngyn). All rights reserved. Use, copying, modification, and redistribution require prior written permission. Third-party components retain their own licenses.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,Ct as t,Dt as n,Q as r,Rt as i,et as a,in as o,it as s,ln as c,on as l,ot as u,tt as d}from"./editor-CE07wW83.js";import{y as f}from"./context-dY4fNbn3.js";import{$ as p,Q as m,bn as h,tt as g}from"./gateway-BAyQgCse.js";var _={"authentication.password.changed":{filterLabel:`Password changed`,icon:`i-lucide-key-round`,label:`changed the password for`},"authentication.password.reset":{filterLabel:`Password reset`,icon:`i-lucide-key-round`,label:`reset the password for`},"authentication.signed-in":{filterLabel:`Signed in`,icon:`i-lucide-log-in`,label:`signed in as`},"authentication.signed-out":{filterLabel:`Signed out`,icon:`i-lucide-log-out`,label:`signed out as`},"document.created":{filterLabel:`Created`,icon:`i-lucide-file-plus`,label:`created`},"document.moved":{filterLabel:`Moved`,icon:`i-lucide-file-symlink`,label:`moved`},"document.published":{filterLabel:`Published`,icon:`i-lucide-send`,label:`published`},"document.trashed":{filterLabel:`Moved to trash`,icon:`i-lucide-trash-2`,label:`moved to trash`},"document.revision.restored":{filterLabel:`Restored revision`,icon:`i-lucide-history`,label:`restored a revision of`},"document.untrashed":{filterLabel:`Restored from trash`,icon:`i-lucide-archive-restore`,label:`restored from trash`},"document.updated":{filterLabel:`Updated`,icon:`i-lucide-pencil-line`,label:`updated`},"media.cleaned":{filterLabel:`Media cleaned`,icon:`i-lucide-sparkles`,label:`cleaned up`},"media.removed":{filterLabel:`Media removed`,icon:`i-lucide-image-minus`,label:`removed`},"media.replaced":{filterLabel:`Media replaced`,icon:`i-lucide-images`,label:`replaced`},"media.uploaded":{filterLabel:`Media uploaded`,icon:`i-lucide-image-plus`,label:`uploaded`},"user.created":{filterLabel:`User added`,icon:`i-lucide-user-plus`,label:`added`},"user.removed":{filterLabel:`User removed`,icon:`i-lucide-user-minus`,label:`removed`},"user.role.changed":{filterLabel:`User role changed`,icon:`i-lucide-shield-check`,label:`changed the role for`},"user.sessions.revoked":{filterLabel:`User sessions revoked`,icon:`i-lucide-log-out`,label:`revoked sessions for`}},v=[{label:`All actions`,value:`all`},...Object.entries(_).map(([e,t])=>({label:t.filterLabel,value:e}))];function y(e){return _[e.action].icon}function b(e){return _[e.action].label}function x(e){for(let t of[`sourcePath`,`objectKey`,`email`]){let n=e.details[t];if(h(n))return n}switch(e.target.kind){case`document`:return e.target.documentId;case`media`:return e.target.mediaId;case`user`:return e.target.userId;case`media-library`:return`Media library`}}function S(e,t){let n=e.target.kind===`document`?e.target.documentId:void 0;return n&&t.has(n)?n:void 0}function C(e,t=g(p())){let n=g(e),r=Math.round((n-t)/1e3),i=new Intl.RelativeTimeFormat(void 0,{numeric:`auto`});if(Math.abs(r)<60)return i.format(r,`second`);let a=Math.round(r/60);if(Math.abs(a)<60)return i.format(a,`minute`);let o=Math.round(a/60);if(Math.abs(o)<24)return i.format(o,`hour`);let s=Math.round(o/24);return Math.abs(s)<30?i.format(s,`day`):new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(n)}var w={class:`text-muted`},T={key:0,class:`font-medium`},E={key:0,class:`block truncate font-mono text-[11px] text-muted`},D={key:1,class:`mt-0.5 block text-dimmed`},O={key:2,class:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted`},k=[`title`],A={class:`font-mono text-[10px]`},j=u({__name:`ActivityEntryRow`,props:{clickable:{type:Boolean,default:!1},compact:{type:Boolean,default:!1},entry:{}},emits:[`select`],setup(u,{emit:p}){let h=p;return(p,g)=>{let _=f;return t(),e(n(u.clickable?`button`:`div`),{type:u.clickable?`button`:void 0,class:l([`flex w-full text-left transition-colors`,[u.compact?`gap-3 px-4 py-3`:`gap-4 px-4 py-4 sm:px-5`,u.clickable?`hover:bg-muted/40`:`cursor-default`]]),onClick:g[0]||=e=>u.clickable&&h(`select`)},{default:i(()=>[r(`span`,{class:l([`grid shrink-0 place-items-center rounded-full bg-muted/50`,u.compact?`mt-0.5 size-7`:`size-9 border border-default`])},[s(_,{name:o(y)(u.entry),class:l(u.compact?`size-3.5 text-muted`:`size-4 text-muted`)},null,8,[`name`,`class`])],2),r(`span`,{class:l([`min-w-0 flex-1`,u.compact?`text-xs`:``])},[r(`span`,{class:l(u.compact?``:`block text-sm text-highlighted`)},[r(`span`,{class:l(u.compact?`font-medium text-highlighted`:`font-semibold`)},c(u.entry.actor.name),3),r(`span`,w,c(o(b)(u.entry)),1),u.compact?a(``,!0):(t(),d(`span`,T,c(o(x)(u.entry)),1))],2),u.compact?(t(),d(`span`,E,c(o(x)(u.entry)),1)):a(``,!0),u.compact?(t(),d(`span`,D,c(o(C)(u.entry.occurredAt)),1)):(t(),d(`span`,O,[r(`span`,{title:o(m).toDate(u.entry.occurredAt).toLocaleString()},c(o(C)(u.entry.occurredAt)),9,k),g[1]||=r(`span`,{"aria-hidden":`true`},`·`,-1),r(`span`,null,c(u.entry.actor.email),1),g[2]||=r(`span`,{"aria-hidden":`true`},`·`,-1),r(`span`,A,c(u.entry.requestId),1)]))],2),u.clickable&&!u.compact?(t(),e(_,{key:0,name:`i-lucide-chevron-right`,class:`mt-2 size-4 shrink-0 text-dimmed`})):a(``,!0)]),_:1},8,[`type`,`class`])}}});export{S as a,x as i,v as n,b as r,j as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,Ct as t,J as n,Jt as r,Kt as i,Pt as a,Q as o,Qt as s,Rt as c,Tt as l,Wt as u,Yt as d,Z as f,bt as p,et as m,in as h,it as g,nt as _,ot as v,tt as y}from"./editor-CE07wW83.js";import{N as b,i as x,n as S,r as C,y as w}from"./context-dY4fNbn3.js";import{t as T}from"./Input-DVao38h7.js";import{t as E}from"./Select-BJZIs9sY.js";import{n as D}from"./gateway-BAyQgCse.js";import{p as O,s as k}from"./index-CjoaPLhZ.js";import{t as A}from"./Skeleton-CWJNi3nS.js";import{a as j,i as M,n as N,r as P,t as F}from"./ActivityEntryRow-D--fRvWI.js";import{t as I}from"./StudioPageHeader-DP9HDAF2.js";function L(e){let t=s([]),n=s(),o=s(!1),c=s(),l=d(`all`),u=d(``),p=0,m=f(()=>{let e=u.value.trim().toLocaleLowerCase();return e?t.value.filter(t=>[t.actor.name,t.actor.email,M(t),P(t)].some(t=>t.toLocaleLowerCase().includes(e))):t.value}),h=async()=>{let r=++p;o.value=!0,c.value=void 0;try{let i=await e.activity.list({action:l.value===`all`?void 0:l.value,limit:50});if(r!==p)return;t.value=i.entries,n.value=i.nextCursor}catch(e){r===p&&(c.value=e)}finally{r===p&&(o.value=!1)}},g=async()=>{let r=n.value;if(!r||o.value)return;let i=p;o.value=!0,c.value=void 0;try{let a=await e.activity.list({action:l.value===`all`?void 0:l.value,cursor:r,limit:50});if(i!==p)return;let o=new Map(t.value.map(e=>[e.id,e]));for(let e of a.entries)o.set(e.id,e);t.value=[...o.values()],n.value=a.nextCursor}catch(e){i===p&&(c.value=e)}finally{i===p&&(o.value=!1)}},_=a(l,h);return i(()=>{p+=1,_()}),{action:l,entries:r(t),error:r(c),isLoading:r(o),load:h,loadMore:g,nextCursor:r(n),search:u,visibleEntries:m}}var R={class:`mx-auto w-full max-w-5xl space-y-7 p-5 sm:p-7 lg:p-9`},z={class:`flex flex-col gap-2 sm:flex-row`},B={key:1,class:`space-y-4 p-5`},V={key:2,class:`divide-y divide-default`},H={key:3,class:`px-6 py-16 text-center`},U={class:`mx-auto grid size-11 place-items-center rounded-full bg-muted`},W={class:`flex justify-center`},G=v({__name:`ActivityView`,setup(r){let{gateway:i}=S(),{catalog:a}=k(),s=b(),d=L(i),{action:v,entries:M,loadMore:P,nextCursor:G,search:K,visibleEntries:q}=d,J=d.isLoading,Y=f(()=>{let e=d.error.value;return e?D(e):``}),X=d.load,Z=f(()=>new Set(a.entries.value.map(e=>e.document.id)));p(X);function Q(e){return j(e,Z.value)}function $(e){let t=Q(e);t&&s.push({name:`documents`,query:{document:t}})}return(r,i)=>{let a=T,s=E,d=x,f=C,p=A,b=w,S=O;return t(),y(`div`,R,[g(I,{title:`Activity`,description:`An immutable record of Document, Media, and User administration, with authentication activity as it becomes available.`}),g(S,{ui:{body:`p-0 sm:p-0`}},_({header:c(()=>[o(`div`,z,[g(a,{modelValue:h(K),"onUpdate:modelValue":i[0]||=e=>u(K)?K.value=e:null,icon:`i-lucide-search`,placeholder:`Filter loaded activity`,class:`min-w-0 flex-1`},null,8,[`modelValue`]),g(s,{modelValue:h(v),"onUpdate:modelValue":i[1]||=e=>u(v)?v.value=e:null,items:h(N),"value-key":`value`,class:`w-full sm:w-44`},null,8,[`modelValue`,`items`]),g(d,{color:`neutral`,variant:`outline`,icon:`i-lucide-refresh-cw`,"aria-label":`Refresh`,loading:h(J),onClick:h(X)},null,8,[`loading`,`onClick`])])]),default:c(()=>[Y.value?(t(),e(f,{key:0,title:`Activity could not be loaded`,description:Y.value,color:`error`,variant:`subtle`,class:`m-4`},null,8,[`description`])):m(``,!0),h(J)&&!h(M).length?(t(),y(`div`,B,[(t(),y(n,null,l(7,e=>g(p,{key:e,class:`h-12`})),64))])):h(q).length?(t(),y(`div`,V,[(t(!0),y(n,null,l(h(q),n=>(t(),e(F,{key:n.id,entry:n,clickable:Q(n)!==void 0,onSelect:e=>$(n)},null,8,[`entry`,`clickable`,`onSelect`]))),128))])):(t(),y(`div`,H,[o(`span`,U,[g(b,{name:`i-lucide-activity`,class:`size-5 text-muted`})]),i[2]||=o(`p`,{class:`mt-3 text-sm font-medium text-highlighted`},`No matching activity`,-1),i[3]||=o(`p`,{class:`mt-1 text-xs text-muted`},` Document, Media, User administration, and authentication activity will appear here. `,-1)]))]),_:2},[h(G)?{name:`footer`,fn:c(()=>[o(`div`,W,[g(d,{color:`neutral`,variant:`outline`,label:`Load more`,loading:h(J),onClick:h(P)},null,8,[`loading`,`onClick`])])]),key:`0`}:void 0]),1024)])}}});export{G as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,Ct as t,J as n,K as r,Pt as i,Q as a,Qt as o,Rt as s,Tt as c,Yt as l,Z as u,et as d,in as f,it as p,jt as m,ln as h,on as g,ot as _,pt as v,tt as y}from"./editor-CE07wW83.js";import{i as ee,n as b,r as te}from"./context-dY4fNbn3.js";import{t as ne}from"./Input-DVao38h7.js";import{t as re}from"./Select-BJZIs9sY.js";import{r as ie,t as ae}from"./Modal-VNrXGa5C.js";import{A as x,B as S,bn as C,dn as w,fn as T,h as E,ln as D,m as O,mn as k,n as oe,p as A,pn as j,pt as M,q as N,un as P,x as F,y as I}from"./gateway-BAyQgCse.js";import{t as L}from"./render-BkxbK2St.js";var R=/:([a-z][\w.]*)(\*)?/giu;function z(e){let t=[...e.matchAll(R)].map(e=>({catchAll:e[2]===`*`,name:e[1]??``}));return e.replace(R,``).includes(`:`)||t.some(e=>!e.name)?D({field:`addressPattern`,message:`Document address pattern "${e}" contains an invalid token.`}):t.filter(e=>e.catchAll).length>1?D({field:`addressPattern`,message:`Document address pattern "${e}" contains more than one catch-all token.`}):new Set(t.map(e=>e.name)).size===t.length?k({pattern:e,tokens:t}):D({field:`addressPattern`,message:`Document address pattern "${e}" contains duplicate tokens.`})}function B(e,t,n){let r=t===`/`?``:t.slice(1),i=e.pattern;for(let t of e.tokens){let a=G(n,t.name),o=t.catchAll?r:void 0,s=a===void 0?o:C(a)&&a.trim()?a:void 0;if(s===void 0)return D({field:t.name,message:a===void 0?`Document address field "${t.name}" is required by pattern "${e.pattern}".`:`Document address field "${t.name}" must be a non-empty string.`});let c=t.catchAll?U(s):W(s);if(w(c))return D(c.failure);i=i.replace(`:${t.name}${t.catchAll?`*`:``}`,c.success)}return H(i)}function V(e,t,n){return!n||!t||t===n.defaultLocale&&!n.prefixDefaultLocale?e:I.make(`/${t}${e===`/`?``:e}`)}function H(e){let t=`/${e.replace(/\\/gu,`/`).replace(/^\/+|\/+$/gu,``)}`.replace(/\/{2,}/gu,`/`);return S(I)(t).pipe(j(()=>({field:`path`,message:`Document path "${e}" cannot be normalized into a public path.`})))}function U(e){if(!e.trim())return k(``);let t=e.replace(/\\/gu,`/`).split(`/`).filter(Boolean),n=[];for(let e of t){let t=W(e);if(w(t))return t;n.push(t.success)}return k(n.join(`/`))}function W(e){let t=e.trim().normalize(`NFKC`).toLocaleLowerCase().replace(/[^\p{Letter}\p{Number}_-]+/gu,`-`).replace(/^-+|-+$/gu,``);return t?k(t):D({message:`Document path segment "${e}" is empty after normalization.`})}function G(e,t){return t.split(`.`).reduce((e,t)=>{if(N(x)(e))return e[t]},e)}function K(e,t){return P(function*(){let n=e.types.find(e=>e.collection===t.collection);if(!n)return yield*Q(`Document collection "${t.collection}" does not exist.`,`collection`);if(!n.canCreate)return yield*Q(`Document collection "${t.collection}" does not allow creation.`,`collection`);let r=t.title.trim();if(!r)return yield*Q(`A document title is required.`,`title`);let i=yield*le(e,t.locale),a=yield*z(n.addressPattern).pipe(j(Z)),o=yield*ue(n,t.location),s=Object.fromEntries(a.tokens.flatMap(e=>e.name===`slug`&&o?[[e.name,o.split(`/`).at(-1)??o]]:[])),c=yield*B(a,yield*H(o).pipe(j(Z)),s).pipe(j(Z)),l=q(n,o,i),u=V(c,i,e.locales);return Object.assign({collection:n,data:s,key:c,path:u,sourcePath:l,title:r},i===void 0?void 0:{locale:i})})}M(`DocumentPlanning.createInitialSource`)(function*(e){let t=O.make({frontmatter:J(e),meta:{},nodes:[[`h1`,{},e.title]]});return{body:t,markdown:yield*L(t)}});function se(e,t){let n=t.sourcePath;return t.document.locale&&n.startsWith(`${t.document.locale}/`)&&(n=n.slice(t.document.locale.length+1)),e.directory!==`.`&&n.startsWith(`${e.directory}/`)&&(n=n.slice(e.directory.length+1)),n=n.replace(/\.(?:md|mdc)$/iu,``),n.toLocaleLowerCase()===`index`?void 0:n}function q(e,t,n){let r=t?`${t}.md`:`index.md`;return F.make([n,e.directory===`.`?void 0:e.directory,r].filter(e=>e!==void 0).join(`/`))}function J(e){let t={...e.data,title:e.title};for(let n of e.collection.authoringFields)n.defaultValue!==void 0&&ce(t,n.path)===void 0&&(t=Y(t,n.path.split(`.`),n.defaultValue));return t}function ce(e,t){return t.split(`.`).reduce((e,t)=>X(e)?e[t]:void 0,e)}function Y(e,t,n){let[r,...i]=t;if(!r)return e;if(i.length===0)return Object.assign({},e,{[r]:n});let a=e[r];return Object.assign({},e,{[r]:Y(X(a)?a:{},i,n)})}var X=N(x);function le(e,t){let n=e.locales;if(!n)return t===void 0?k(void 0):Q(`Document locale "${t}" is not configured.`,`locale`);let r=t??n.defaultLocale;return n.locales.includes(r)?k(r):Q(`Document locale "${r}" does not exist.`,`locale`)}function ue(e,t){return t.kind===`home`?e.addressPattern===`/:path*`?k(``):Q(`Only a root catch-all collection can use the home location.`,`location`):t.parent!==void 0&&!e.hierarchy?Q(`Document collection "${e.collection}" does not allow hierarchy.`,`location.parent`):U([t.parent,t.slug].filter(e=>e!==void 0).join(`/`)).pipe(j(e=>Z({...e,field:`location`})))}function Z(e){return new A({issues:[de(e.message,e.field)]})}function Q(e,t){return D(new A({issues:[de(e,t)]}))}function de(e,t){return t===void 0?{code:`document.invalid`,message:e,severity:`error`}:{code:`document.invalid`,field:t,message:e,severity:`error`}}function fe(e,t){let n=S(E)(t);if(w(n))return D(`The document details are invalid.`);let r=K(e,n.success);return T(r)?k({path:r.success.path,sourcePath:r.success.sourcePath}):D(r.failure.issues[0]?.message||`The document location is invalid.`)}function pe(e){return e.trim().normalize(`NFKC`).toLocaleLowerCase().replace(/[^\p{Letter}\p{Number}_-]+/gu,`-`).replace(/^-+|-+$/gu,``)}var me={key:2},he={class:`grid grid-flow-col auto-cols-fr overflow-x-auto rounded-md border border-default`},ge=[`title`,`onClick`],_e={class:`block truncate`},ve={key:0,class:`mt-2 flex min-w-0 items-center justify-between gap-3 text-xs text-muted`},ye={class:`truncate`},be={class:`shrink-0 font-mono text-[11px] text-dimmed`},xe={key:5,class:`flex min-w-0 items-center gap-3 rounded-md border border-default px-3 py-2`},Se={key:6,class:`-mt-2 text-xs text-error`},Ce={key:7,class:`-mt-2 text-xs text-error`},we={class:`flex w-full justify-end gap-2`},$=`__top_level__`,Te=_({__name:`CreateDocumentDialog`,props:v({catalog:{}},{open:{type:Boolean},openModifiers:{}}),emits:v([`close`],[`update:open`]),setup(_,{emit:v}){let x=v,S=m(_,`open`),C=b(),E=C.bootstrap.documents,D=E.types.filter(e=>e.canCreate),O=(E.locales?.locales??[]).map(e=>({label:J(e),value:e})),k=o(``),A=o(!1),j=l(``),M=l(``),N=l(!1),P=l(``),F=l($),I=l(E.locales?.defaultLocale??``),L=u(()=>{let e=D.map(e=>({collection:e.collection,description:e.description,key:`entry:${e.collection}`,kind:`entry`,label:e.label,type:e,urlHint:e.addressPattern.replace(/:[a-z][\w.]*\*?/giu,`…`)}));return[...D.filter(e=>e.addressPattern===`/:path*`).slice(0,1).flatMap(e=>{let t=fe(E,{collection:e.collection,locale:I.value||void 0,location:{kind:`home`},title:`Home`});return w(t)||_.catalog.entries.value.some(e=>e.document.path===t.success.path)?[]:[{collection:e.collection,description:`The first document visitors see when they open the website.`,key:`home:${e.collection}`,kind:`home`,label:`Home`,type:e,urlHint:t.success.path}]}),...e]}),R=u(()=>L.value.find(e=>e.key===P.value)),z=u(()=>R.value?.kind===`home`?{kind:`home`}:F.value===$?{kind:`entry`,slug:M.value}:{kind:`entry`,parent:F.value,slug:M.value}),B=u(()=>{let e=R.value;if(!e||e.kind===`entry`&&!M.value.trim())return;let t={collection:e.collection,location:z.value,title:j.value||`Untitled`};return fe(E,I.value?{...t,locale:I.value}:t)}),V=u(()=>{let e=B.value;return e&&T(e)?e.success:void 0}),H=u(()=>{let e=B.value;return e&&w(e)?e.failure:``}),U=u(()=>V.value&&_.catalog.entries.value.some(e=>e.document.path===V.value?.path)),W=u(()=>{let e=R.value;if(!e||e.kind===`home`||!e.type.hierarchy)return[];let t=_.catalog.entries.value.flatMap(t=>{if(t.document.collection!==e.collection||t.document.locale!==(I.value||void 0))return[];let n=se(e.type,t);return n?[{label:`${t.document.title} · /${n}`,value:n}]:[]});return[{label:`Top level`,value:$},...t]}),G=u(()=>!!j.value.trim()&&!!R.value&&!!V.value&&!U.value);i(j,e=>{N.value||(M.value=pe(e))}),i(P,()=>F.value=$),i(I,()=>{F.value=$,R.value||(P.value=q())}),i(S,e=>{e&&(k.value=``,j.value=``,M.value=``,N.value=!1,F.value=$,I.value=E.locales?.defaultLocale??``,P.value=q())},{immediate:!0});async function K(){let e=R.value;if(G.value&&e&&!A.value){A.value=!0,k.value=``;try{let t={collection:e.collection,location:z.value,title:j.value},n=await C.gateway.documents.create(I.value?{...t,locale:I.value}:t);await _.catalog.refresh(!0);let r=_.catalog.byId(n.documentId);if(!r)throw Error(`The page was created but could not be opened.`);x(`close`,r.document.id)}catch(e){k.value=oe(e)}finally{A.value=!1}}}function q(){return L.value[0]?.key??``}function J(e){try{return new Intl.DisplayNames(void 0,{type:`language`}).of(e)??e.toLocaleUpperCase()}catch{return e.toLocaleUpperCase()}}return(i,o)=>{let l=te,u=ne,m=ie,_=re,v=ee,b=ae;return t(),e(b,{open:S.value,"onUpdate:open":o[6]||=e=>S.value=e,title:`New document`,description:`Add a document to your website.`,ui:{content:`max-w-lg`}},{body:s(()=>[a(`form`,{id:`create-document-form`,class:`space-y-4`,onSubmit:r(K,[`prevent`])},[k.value?(t(),e(l,{key:0,description:k.value,color:`error`,variant:`subtle`},null,8,[`description`])):d(``,!0),L.value.length?L.value.length>1?(t(),y(`fieldset`,me,[o[7]||=a(`legend`,{class:`mb-2 text-sm font-medium text-highlighted`},`Collection`,-1),a(`div`,he,[(t(!0),y(n,null,c(L.value,e=>(t(),y(`button`,{key:e.key,type:`button`,title:e.description,class:g([`min-w-28 border-l border-default px-3 py-2 text-center text-sm transition-colors first:border-l-0`,e.key===P.value?`bg-muted font-medium text-highlighted`:`bg-default text-muted hover:bg-muted/50 hover:text-highlighted`]),onClick:t=>P.value=e.key},[a(`span`,_e,h(e.label),1)],10,ge))),128))]),R.value?(t(),y(`div`,ve,[a(`span`,ye,h(R.value.description),1),a(`code`,be,h(R.value.urlHint),1)])):d(``,!0)])):d(``,!0):(t(),e(l,{key:1,title:`Document creation is not configured`,description:`A developer needs to make at least one collection creatable in Studio.`,color:`warning`,variant:`subtle`})),R.value?(t(),y(`div`,{key:3,class:g([`grid gap-4`,f(O).length?`sm:grid-cols-[minmax(0,2fr)_minmax(9rem,1fr)]`:``])},[p(m,{label:`Title`,required:``},{default:s(()=>[p(u,{modelValue:j.value,"onUpdate:modelValue":o[0]||=e=>j.value=e,autofocus:``,placeholder:`About us`,class:`w-full`},null,8,[`modelValue`])]),_:1}),f(O).length?(t(),e(m,{key:0,label:`Language`},{default:s(()=>[p(_,{modelValue:I.value,"onUpdate:modelValue":o[1]||=e=>I.value=e,items:f(O),"value-key":`value`,class:`w-full`},null,8,[`modelValue`,`items`])]),_:1})):d(``,!0)],2)):d(``,!0),R.value?.kind===`entry`?(t(),y(`div`,{key:4,class:g([`grid gap-4`,R.value.type.hierarchy?`sm:grid-cols-2`:``])},[R.value.type.hierarchy?(t(),e(m,{key:0,label:`Parent document`},{default:s(()=>[p(_,{modelValue:F.value,"onUpdate:modelValue":o[2]||=e=>F.value=e,items:W.value,"value-key":`value`,class:`w-full`},null,8,[`modelValue`,`items`])]),_:1})):d(``,!0),p(m,{label:`URL ending`,required:``},{default:s(()=>[p(u,{modelValue:M.value,"onUpdate:modelValue":[o[3]||=e=>M.value=e,o[4]||=e=>N.value=!0],placeholder:`about-us`,class:`w-full`},null,8,[`modelValue`])]),_:1})],2)):d(``,!0),R.value?(t(),y(`div`,xe,[o[8]||=a(`span`,{class:`shrink-0 text-xs text-muted`},`URL`,-1),a(`p`,{class:g([`min-w-0 flex-1 truncate text-right font-mono text-xs`,U.value?`text-error`:`text-highlighted`])},h(V.value?.path||R.value.urlHint),3)])):d(``,!0),U.value?(t(),y(`p`,Se,`This URL is already in use.`)):H.value?(t(),y(`p`,Ce,h(H.value),1)):d(``,!0)],32)]),footer:s(()=>[a(`div`,we,[p(v,{color:`neutral`,variant:`ghost`,label:`Cancel`,onClick:o[5]||=e=>S.value=!1}),p(v,{type:`submit`,form:`create-document-form`,color:`neutral`,label:`Create document`,loading:A.value,disabled:!G.value},null,8,[`loading`,`disabled`])])]),_:1},8,[`open`])}}});export{Te as default};
|